package android.slc.box.core.launcher;

import android.slc.box.core.controller.EventPlusHandler;
import android.slc.box.core.virtual_android.Bundle;
import de.saxsys.mvvmfx.FxmlView;
import de.saxsys.mvvmfx.Scope;
import de.saxsys.mvvmfx.ViewModel;
import de.saxsys.mvvmfx.ViewTuple;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Window;

import java.util.Collection;
import java.util.List;

public interface WindowLauncherBridge<WL extends WindowLauncher<T>, T extends Window> extends WindowLauncher<T> {

    @Override
    default T getWindow() {
        return getWindowLauncher().requireWindow();
    }

    @Override
    default List<String> getStylesheets() {
        return getWindowLauncher().getStylesheets();
    }

    @Override
    default Bundle getBundle() {
        return getWindowLauncher().getBundle();
    }

    /**
     * 添加窗口关闭监听
     *
     * @param onWindowsCloseListener
     */
    @Override
    default void addOnWindowsCloseListener(EventPlusHandler.EventPlusHandlerListener onWindowsCloseListener) {
        getWindowLauncher().addOnWindowsCloseListener(onWindowsCloseListener);
    }

    /**
     * 移除窗口关闭监听
     *
     * @param onWindowsCloseListener
     */
    @Override
    default void removeOnWindowsCloseListener(EventPlusHandler.EventPlusHandlerListener onWindowsCloseListener) {
        getWindowLauncher().removeOnWindowsCloseListener(onWindowsCloseListener);
    }

    /**
     * 切换场景
     * 此处是不合理的
     *
     * @param scene 传递一个场景
     */
    @Deprecated
    @Override
    default void switchScene(Scene scene) {
        getWindowLauncher().switchScene(scene);
    }

    @Override
    default <ViewType extends FxmlView<? extends ViewModelType>, ViewModelType extends ViewModel> void switchView(Class<ViewType> viewClass, Bundle bundle, Scope... scopes) {
        getWindowLauncher().switchView(viewClass, bundle, scopes);
    }

    @Override
    default <ViewType extends FxmlView<? extends ViewModelType>, ViewModelType extends ViewModel> void addView(Pane parentPane, Class<ViewType> viewClass, Bundle bundle, Scope... scopes) {
        getWindowLauncher().addView(parentPane, viewClass, bundle, scopes);
    }

    @Override
    default void addView(Pane parentPane, Parent contentView) {
        getWindowLauncher().addView(parentPane, contentView);
    }

    @Override
    default <ViewType extends FxmlView<? extends ViewModelType>, ViewModelType extends ViewModel> Parent createView(Class<ViewType> viewClass, Bundle bundle, Scope... scopes) {
        return getWindowLauncher().createView(viewClass, bundle, scopes);
    }

    @Override
    default void launcherWindow(T targetWindow, Scene scene) {
        getWindowLauncher().launcherWindow(targetWindow, scene);
    }

    @Override
    default <ViewType extends FxmlView<? extends ViewModelType>, ViewModelType extends ViewModel> ViewTuple<ViewType, ViewModelType> createViewTuple(Class<ViewType> viewClass,
                                                                                                                                                     Collection<Scope> scopes) {
        return getWindowLauncher().createViewTuple(viewClass, scopes);
    }

    /**
     * 获取获取StageScope
     *
     * @return
     */
    WL getWindowLauncher();
}
